package com.eddy.controller;

import com.eddy.entity.MainMenu;
import com.eddy.service.MenuService;
import com.eddy.util.DataUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class MenuController {
    private static Logger log = Logger.getLogger(MenuController.class);

    @Autowired
    private MenuService menuService;

    @RequestMapping("/menus")
    public String getAllMenu(){
        try {
            List<MainMenu> menus = menuService.getMenus();
            if(menus != null) {
                return DataUtils.resultData(menus, "OK");
            }
        }catch (Exception e){
            log.error("Get All Menu Exception:",e);
        }
        return DataUtils.resultData("Error");
    }
}
